package com.lang.dao.impl;

import com.lang.dao.TypeDao;
import com.lang.entity.Type;
import com.lang.service.TypeService;
import com.lang.utils.C3P0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/*
 * @Date : 2024/3/13 9:29
 * @Created by Lang
 * @ProjectName : LclShop
 */
public class TypeDaoImpl implements TypeDao {
    private QueryRunner runner = new QueryRunner(C3P0Utils.getDataSource());
    @Override
    public List<Type> list() {
        String sql = "select * from type";
        try {
           return runner.query(sql,new BeanListHandler<>(Type.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
